<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmNewProfile">

        <p:dialog id="dlgNewProfile" 
                  header="Nuevo Perfil" 
                  widgetVar="dlgNewProfile" 
                  resizable="false" 
                  modal="true" 
                  closable="false"
                  onShow="#{profileBean.prepareCreate()}">

            <h:panelGrid columns="2" cellpadding="4" style="margin:0 auto;">
                <h:outputText value="Código"/>
                <p:inputText value="#{profileBean.profile.prfCode}"
                             style="50px"
                             maxlength="4"
                             required="true"
                             />
                <h:outputText value="Nombre del Perfil"/>
                <p:inputText maxlength="50" 
                             value="#{profileBean.profile.prfName}" 
                             style="300px"
                             required="true"/>
            </h:panelGrid>
            <p:separator/>

            <br/><h:outputText value="Mantenimiento"/>

            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmUser}"/>
                <h:outputText value="Usuarios"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmProf}"/>
                <h:outputText value="Perfiles"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmStdn}"/>
                <h:outputText value="Estudiantes"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmLvls}"/>
                <h:outputText value="Niveles de Formación"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmFclt}"/>
                <h:outputText value="Facultades"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmProg}"/>
                <h:outputText value="Programas"/>
            </h:panelGrid>

            <br/><h:outputText value="Imprimir"/>

            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuImprLiqn}"/>
                <h:outputText value="Liquidaciones"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuImprCrtf}"/>
                <h:outputText value="Certificados"/>
            </h:panelGrid>

            <br/><h:outputText value="Herramientas"/>
            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox
                    value="#{profileBean.profile.prfMenuToolPswc}"/>
                <h:outputText value="Actualizar Contraseña"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuToolBckp}"/>
                <h:outputText value="Realizar Copia de Seguridad"/>
            </h:panelGrid>

            <p:separator/>
            <div align="center">
                <p:commandButton value="Guardar" 
                                 update=":frmPrincipal:messages"
                                 ajax="false"
                                 actionListener="#{profileBean.createProfile()}"/>
                <p:commandButton value="Cancelar" 
                                 update=":body, :frmPrincipal:messages"
                                 oncomplete="dlgNewProfile.hide();"/>
            </div>

        </p:dialog>

    </h:form>

    <h:form id="frmEditProfile">
        <p:dialog id="dlgEditProfile" 
                  header="Editar Perfil" 
                  widgetVar="dlgEditProfile" 
                  resizable="false" 
                  modal="true" 
                  closable="false">

            <p:inputText value="#{profileBean.profile.prfCode}" 
                         style="display: none"/>

            <h:panelGrid columns="2" cellpadding="4" style="margin:0 auto;">

                <h:outputText value="Nombre del Perfil"/>
                <p:inputText maxlength="50" 
                             value="#{profileBean.profile.prfName}" 
                             style="300px"
                             required="true"/>

            </h:panelGrid>

            <p:separator/>

            <br/><h:outputText value="Mantenimiento"/>

            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmUser}"/>
                <h:outputText value="Usuarios"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmProf}"/>
                <h:outputText value="Perfiles"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmStdn}"/>
                <h:outputText value="Estudiantes"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmLvls}"/>
                <h:outputText value="Niveles de Formación"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmFclt}"/>
                <h:outputText value="Facultades"/>
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuMngmProg}"/>
                <h:outputText value="Programas"/>
            </h:panelGrid>

            <br/><h:outputText value="Imprimir"/>

            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuImprLiqn}"/>
                <h:outputText value="Liquidaciones"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuImprCrtf}"/>
                <h:outputText value="Certificados"/>
            </h:panelGrid>

            <br/><h:outputText value="Herramientas"/>
            <h:panelGrid columns="2">
                <p:selectBooleanCheckbox
                    value="#{profileBean.profile.prfMenuToolPswc}"/>
                <h:outputText value="Actualizar Contraseña"/>     
                <p:selectBooleanCheckbox 
                    value="#{profileBean.profile.prfMenuToolBckp}"/>
                <h:outputText value="Realizar Copia de Seguridad"/>
            </h:panelGrid>
            <p:separator/>

            <div align="center">
                <p:commandButton value="Actualizar" 
                                 update=":body, :frmPrincipal:messages"
                                 ajax ="false"
                                 oncomplete="dlgEditProfile.hide();" 
                                 actionListener="#{profileBean.updateProfile(actionEvent)}"/>
                <p:commandButton value="Cancelar" 
                                 update=":body, :frmPrincipal:messages"
                                 oncomplete="dlgEditProfile.hide();"/>
            </div>

        </p:dialog>

    </h:form>

    <h:form id="frmDeleteProfile">

        <p:confirmDialog id="dlgDeleteProfile" 
                         header="#{etq.appName}"
                         message="Desea Eliminar el Perfil: '#{profileBean.profile.prfName}'"
                         severity="alert"
                         widgetVar="dlgDeleteProfile">

            <div align="center">
                <p:commandButton value="Eliminar"
                                 actionListener="#{profileBean.deleteProfile(actionEvent, profileBean.profile.prfCode)}"
                                 ajax="false"
                                 update=":body, :frmPrincipal:messages"
                                 oncomplete="dlgDeleteProfile.hide()"
                                 icon="ui-icon-check"/>                 
                <p:commandButton value="Cancelar"
                                 oncomplete="dlgDeleteProfile.hide()"
                                 icon="ui-icon-circle-close"/>  
            </div>

        </p:confirmDialog>

    </h:form>

    <h:form id="frmNewUser">

        <p:dialog id="dlgNewUser"
                  header="Nuevo Usuario"
                  widgetVar="dlgNewUser"
                  resizable="false"
                  modal="true"
                  onShow="#{userBean.prepareCreate()}">

            <h:panelGrid columns="2" 
                         cellpadding="4px;"
                         >

                <h:outputText value ="Código: "/>
                <p:inputText value="#{userBean.user.usrCode}"
                             maxlength="20"
                             required="true"/>

                <h:outputText value ="Nombres:"/>
                <p:inputText value="#{userBean.user.usrName}"
                             maxlength="50"
                             required="true"
                             style="width: 235px;"/>

                <h:outputText value ="Apellidos:"/>
                <p:inputText value="#{userBean.user.usrLstn}"
                             maxlength="50"
                             required="true"
                             style="width: 235px;"/>

                <h:outputText value ="Perfil: "/>
                <p:selectOneMenu value="#{userBean.usrPrfCode}" style="width: 243px">
                    <f:selectItems value="#{profileBean.profiles}"
                                   var="profile"
                                   itemLabel="#{profile.prfName}"
                                   itemValue="#{profile.prfCode}"
                                   />
                </p:selectOneMenu>

                <h:outputText value ="Contraseña:"/>
                <p:password value="#{userBean.user.usrPswd}"
                            maxlength="15"
                            required="true"
                            />

                <h:outputText value ="Fecha de Expiración:"/>
                <p:calendar pattern="dd-MM-yyyy"
                            effect="fadeIn"
                            showButtonPanel="true" 
                            navigator="true"
                            yearRange="1950, now"
                            value="#{userBean.user.usrPswdExpiration}"
                            required="true"
                            />

                <h:outputText value="Activo: "/>
                <p:selectBooleanCheckbox value="#{userBean.user.usrActv}"/>

            </h:panelGrid>

            <p:separator/>

            <div align="center">
                <p:commandButton value="Guardar"
                                 oncomplete="dlgNewUser.close();"
                                 update=":body, :frmPrincipal:messages"
                                 ajax="false"
                                 actionListener="#{userBean.createUser()}"
                                 icon="ui-icon-disk"/>
                &nbsp;
                &nbsp;
                &nbsp;
                <p:commandButton value="Cancelar"
                                 oncomplete="dlgNewUser.hide();"
                                 actionListener="#{userBean.prepareCreate()}"
                                 icon="ui-icon-circle-close"/>
            </div>


        </p:dialog>

    </h:form>

    <h:form id="frmEditUser">

        <p:dialog id="dlgEditUser"
                  header="Nuevo Usuario"
                  widgetVar="dlgEditUser"
                  resizable="false"
                  closable="false"
                  modal="true">

            <p:inputText value="#{userBean.user.usrCode}"
                         maxlength="20"
                         style="display: none;"/>

            <h:panelGrid columns="2" 
                         cellpadding="4px;"
                         >

                <h:outputText value ="Nombres:"/>
                <p:inputText value="#{userBean.user.usrName}"
                             maxlength="50"
                             required="true"
                             style="width: 235px;"/>

                <h:outputText value ="Apellidos:"/>
                <p:inputText value="#{userBean.user.usrLstn}"
                             maxlength="50"
                             required="true"
                             style="width: 235px;"/>

                <h:outputText value ="Perfil: "/>
                <p:selectOneMenu value="#{userBean.usrPrfCode}" style="width: 243px">
                    <f:selectItems value="#{profileBean.profiles}"
                                   var="profile"
                                   itemLabel="#{profile.prfName}"
                                   itemValue="#{profile.prfCode}"
                                   />
                </p:selectOneMenu>

                <h:outputText value="Activo: "/>
                <p:selectBooleanCheckbox value="#{userBean.user.usrActv}"/>

            </h:panelGrid>

            <p:separator/>

            <div align="center">
                <p:commandButton value="Actualizar"
                                 oncomplete="dlgEditUser.hide();"
                                 update=":body, :frmPrincipal:messages"
                                 ajax="false"
                                 actionListener="#{userBean.updateUser()}"
                                 icon="ui-icon-disk"/>
                &nbsp;
                &nbsp;
                &nbsp;
                <p:commandButton value="Cancelar"
                                 oncomplete="dlgEditUser.hide();"
                                 icon="ui-icon-circle-close"/>
            </div>


        </p:dialog>

    </h:form>

    <h:form id="frmDeleteUser">

        <p:confirmDialog id="dlgDeleteUser"
                         header="#{etq.appName}"
                         widgetVar="dlgDeleteUser"
                         message="Desea Eliminar el Usuario: '#{userBean.user.usrCode}' "
                         closable="false"
                         severity="alert">

            <div align="center">
                <p:commandButton value="Eliminar"
                                 actionListener="#{userBean.deleteUser()}"
                                 ajax="false"
                                 update=":body, :frmPrincipal:messages"
                                 oncomplete="dlgDeleteUser.close()"
                                 icon="ui-icon-check"/>
                &nbsp;
                &nbsp;
                &nbsp;
                <p:commandButton value="Cancelar"
                                 oncomplete="dlgDeleteUser.close()"
                                 icon="ui-icon-circle-close"/>  
            </div>


        </p:confirmDialog>
    </h:form>

    <h:form id="frmActiveUser">

        <p:dialog id="dlgActiveUser"
                  header="Activar Usuario"
                  widgetVar="dlgActiveUser"
                  resizable="false"
                  modal="true"
                  >

            <p:dataTable id="dtInactiveUsers"
                         var="InactiveUsers"
                         value="#{userBean.users}">

                <p:column headerText="Código">
                    <h:outputText value="#{InactiveUsers.usrCode}"/>
                </p:column>
                <p:column headerText="Nombres">
                    <h:outputText value="#{InactiveUsers.usrName}"/>
                </p:column>
                <p:column headerText="Apellidos">
                    <h:outputText value="#{InactiveUsers.usrLstn}"/>
                </p:column>
                <p:column headerText="Perfil">
                    <h:outputText value="#{InactiveUsers.profiles.prfName}"/>
                </p:column>
                <p:column>
                    <p:commandButton icon="ui-icon-check"
                                     update=":body, :frmPrincipal:messages"
                                     ajax="false"
                                     actionListener="#{userBean.activeUser(InactiveUsers)}"
                                     oncomplete="dlgActiveUser.hide()"
                                     />
                </p:column>

            </p:dataTable>

            <p:separator/>

            <div align="center">

                <p:commandButton value="Cancelar"
                                 update=":body"
                                 ajax="false"
                                 oncomplete="dlgActiveUser.hide()"
                                 icon="ui-icon-circle-close"
                                 actionListener="#{userBean.inactiveUsers(false)}"/>  
            </div>
        </p:dialog>

    </h:form>

    <h:form id="frmNewTurn">

        <p:dialog id="dlgNewTurn" 
                  modal ="true" 
                  header="Siguiente Turno" 
                  widgetVar="dlgNewTurn"
                  closable="false"
                  resizable="false"
                  dynamic="true"
                  >

            <br/>
            <br/>
            <div align ="center">

                <h:outputText id="lblCurrentTurn" 
                              value="#{turnsBean.turn.trnNmbr}"
                              style="font-weight: bolder; font-size: 5em; text-align: center;"/>
            </div>
            <br/>
            <br/>
            <div align="center">

                <p:commandButton value="Aceptar"
                                 update=":body, :frmNewTurn"
                                 ajax="false"
                                 oncomplete="dlgNewTurn.hide()"
                                 action="#{turnsBean.takeTurn()}"
                                 actionListener="#{navigationBean.takeTurn()}"
                                 icon="ui-icon-check"/>
                &nbsp;
                &nbsp;
                <p:commandButton value="Siguiente"
                                 actionListener="#{turnsBean.nextTurn()}"
                                 update="lblCurrentTurn"
                                 icon="ui-icon-seek-next"/>
                &nbsp;
                &nbsp;
                <p:commandButton value="Cancelar"
                                 oncomplete="dlgNewTurn.hide()"
                                 icon="ui-icon-circle-close"/>

            </div>

        </p:dialog>
        
    </h:form>

        <h:form id="frmTurnRate">

            <p:dialog id="dlgTurnRate" 
                      modal ="true" 
                      header="Asignar Calificación Turno" 
                      widgetVar="dlgTurnRate"
                      closable="false"
                      resizable="false"
                      >

                <br/>
                <br/>
                <div align ="center">

                    <h:outputText id="lblCurrentTurn" 
                                  value="Califique la Atención Obtenida"
                                  style="font-weight: bolder; font-size: 2em;"/>
                </div>
                <br/>
                <div align="center">
                    <p:password value="#{turnsBean.turn.trnRate}"
                                required=""/>
                </div>
                <br/>
                <div align="center">

                    <p:commandButton value="Aceptar"
                                     update=":body, :mainpannel"
                                     ajax="false"
                                     oncomplete="dlgTurnRate.hide()"
                                     action="#{navigationBean.blank()}"
                                     actionListener="#{turnsBean.finishTurn()}"
                                     icon="ui-icon-check"/>
                   
                </div>

            </p:dialog>

        </h:form>
</html>